home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / accrd1 / board.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  6.0 KB  |  216 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H0000C000&
  4.    Caption         =   "Accordian"
  5.    ClientHeight    =   4605
  6.    ClientLeft      =   855
  7.    ClientTop       =   1515
  8.    ClientWidth     =   7875
  9.    Height          =   5295
  10.    Icon            =   BOARD.FRX:0000
  11.    Left            =   795
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   4605
  15.    ScaleWidth      =   7875
  16.    Top             =   885
  17.    Width           =   7995
  18.    Begin CommandButton Command1 
  19.       Caption         =   "Deal"
  20.       Default         =   -1  'True
  21.       Height          =   1215
  22.       Left            =   6000
  23.       TabIndex        =   1
  24.       Top             =   240
  25.       Width           =   1695
  26.    End
  27.    Begin PictureBox Picture1 
  28.       AutoSize        =   -1  'True
  29.       BackColor       =   &H00FFFFFF&
  30.       BorderStyle     =   0  'None
  31.       DragMode        =   1  'Automatic
  32.       Height          =   1455
  33.       Index           =   0
  34.       Left            =   120
  35.       ScaleHeight     =   1455
  36.       ScaleWidth      =   1095
  37.       TabIndex        =   0
  38.       Top             =   120
  39.       Width           =   1095
  40.    End
  41.    Begin Menu GameMenu 
  42.       Caption         =   "&Game"
  43.       Begin Menu GameNew 
  44.          Caption         =   "&New Game"
  45.          Shortcut        =   {F2}
  46.       End
  47.       Begin Menu GameUndo 
  48.          Caption         =   "&Undo"
  49.          Shortcut        =   ^H
  50.       End
  51.       Begin Menu GameRecord 
  52.          Caption         =   "&Record of Games"
  53.       End
  54.       Begin Menu GameBar 
  55.          Caption         =   "-"
  56.       End
  57.       Begin Menu GameExit 
  58.          Caption         =   "E&xit"
  59.       End
  60.    End
  61.    Begin Menu OptionMenu 
  62.       Caption         =   "&Options"
  63.       Begin Menu OptionsErrors 
  64.          Caption         =   "Display Errors"
  65.          Checked         =   -1  'True
  66.       End
  67.       Begin Menu OptionsCompressed 
  68.          Caption         =   "Compressed"
  69.          Shortcut        =   {F5}
  70.       End
  71.    End
  72.    Begin Menu HelpMenu 
  73.       Caption         =   "Help"
  74.       Begin Menu HelpIndex 
  75.          Caption         =   "Index"
  76.          Shortcut        =   {F1}
  77.       End
  78.       Begin Menu HelpAbout 
  79.          Caption         =   "&About"
  80.       End
  81.    End
  82. DefInt A-Z
  83. Sub Command1_Click ()
  84.    UndoSave'Save current state
  85.    Piles = Piles + 1
  86.    i = Piles - 1
  87.    Load Picture1(i)
  88.    table(Piles) = cards(NextCard)
  89.    GetCard (cards(NextCard))
  90.    Picture1(i).Picture = ClipBoard.GetData(2)
  91.    Picture1(i).Top = CurrentRow(Piles)
  92.    Picture1(i).Left = CurrentCol(Piles)
  93.    Picture1(i).Visible = -1
  94.    NextCard = NextCard + 1
  95.    If NextCard = 53 Then
  96.      Command1.Enabled = 0
  97.    End If
  98. End Sub
  99. Sub Form_Load ()
  100.    If CardVersion() <> 101 Then
  101.       MsgBox Appname$ + " requires VBCARDS.DLL Version 1.01P", 48, "Version Error!"
  102.       End
  103.    End If
  104.    Undone = -1
  105.    Piles = 1
  106.    OptionsErrors.Checked = DisplayError
  107.    OptionsCompressed.Checked = Compressed
  108.    ShuffleCards
  109.    GetCard (cards(1))
  110.    table(1) = cards(1)
  111.    Picture1(0).Picture = ClipBoard.GetData(2)
  112.    NextCard = 2
  113. End Sub
  114. Sub GameExit_Click ()
  115.    UpdateIni
  116.    End
  117. End Sub
  118. Sub GameNew_Click ()
  119.     NewGame
  120. End Sub
  121. Sub GameRecord_Click ()
  122.    S$ = "Total Games is " + Str$(GamesWon + GamesLost) + Chr$(13) + Chr$(10)
  123.    S$ = S$ + "Games Won  = " + Str$(GamesWon) + Chr$(13) + Chr$(10)
  124.    S$ = S$ + "Games Lost = " + Str$(GamesLost)
  125.    MsgBox S$, 0, "Record of Games"
  126. End Sub
  127. Sub GameUndo_Click ()
  128.     If Undone = 0 Then
  129.        'Expand or Decrease the size of the table
  130.        If UndoPiles > Piles Then
  131.           Load Picture1(Piles)
  132.           Picture1(Piles).Top = CurrentRow(UndoPiles)
  133.           Picture1(Piles).Left = CurrentCol(UndoPiles)
  134.           Picture1(Piles).Visible = -1
  135.        Else
  136.           Unload Picture1(Piles - 1)
  137.        End If
  138.        For i = 1 To UndoPiles
  139.           table(i) = Undoer(i)
  140.           GetCard (Undoer(i))
  141.           Picture1(i - 1).Picture = ClipBoard.GetData(2)
  142.        Next
  143.        
  144.        Piles = UndoPiles
  145.        NextCard = UndoNextCard
  146.        Undone = -1
  147.     Else
  148.        Beep
  149.     End If
  150. End Sub
  151. Sub HelpAbout_Click ()
  152.    Form3.Show 1
  153. End Sub
  154. Sub HelpIndex_Click ()
  155.    X = Shell("WinHelp E:\VB\Card1\Accord.hlp", 1)
  156. End Sub
  157. Sub OptionsCompressed_Click ()
  158.     Compressed = Not Compressed
  159.     OptionsCompressed.Checked = Compressed
  160.     For i = 1 To Piles
  161.        GetCard (table(i))
  162.        Picture1(i - 1).Picture = ClipBoard.GetData(2)
  163.        Picture1(i - 1).Top = CurrentRow(i)
  164.     Next
  165.     Form1.Refresh
  166. End Sub
  167. Sub OptionsErrors_Click ()
  168.     DisplayError = Not DisplayError
  169.     OptionsErrors.Checked = DisplayError
  170. End Sub
  171. Sub Picture1_DblClick (Index As Integer)
  172.    If Index = 0 Then
  173.      Beep
  174.    Else
  175.      If ValidMove(Index, Index - 1) Then
  176.        UndoSave
  177.        Picture1(Index - 1).Picture = Picture1(Index).Picture
  178.        table(Index) = table(Index + 1)
  179.        Compact (Index)
  180.      Else
  181.        If Index > 2 Then
  182.          If ValidMove(Index, Index - 3) Then
  183.             UndoSave
  184.             Picture1(Index - 3).Picture = Picture1(Index).Picture
  185.             table(Index - 2) = table(Index + 1)
  186.             Compact (Index)
  187.           Else
  188.             Beep
  189.           End If
  190.        Else
  191.           Beep
  192.        End If
  193.      End If
  194.    End If
  195. End Sub
  196. Sub Picture1_DragDrop (Index As Integer, Source As Control, X As Single, Y As Single)
  197.    If Source.Index = Index Then
  198.      Exit Sub
  199.    End If
  200.    i% = Source.Index - Index
  201.    If Source.Index < Index Then
  202.       ShowError ("You must move cards towards the top")
  203.    ElseIf (i% <> 1) And (i% <> 3) Then
  204.       ShowError ("Card must be next to, or 4 away from target")
  205.    Else
  206.      If ValidMove(Source.Index, Index) Then
  207.        UndoSave
  208.        Picture1(Index).Picture = Source.Picture
  209.        table(Index + 1) = table(Source.Index + 1)
  210.        Compact (Source.Index)
  211.      Else
  212.        ShowError ("Card must be same suit or same value")
  213.      End If
  214.  End If
  215. End Sub
  216.